package com.tcm.controller.front;

import com.tcm.entity.resp.R;
import com.tcm.service.ExerciseService;
import com.tcm.utils.AccessTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Guqier
 * @version 1.0
 * @date 2023/8/17 12:40
 */
@RestController
@RequestMapping("/stu/exercise")
public class StuExerciseController {

    @Autowired
    private ExerciseService exerciseService;

    /**
     * 学生获取已发布练习
     * @param request 请求对象
     * @return 当前学生的已发布练习
     */
    @RequestMapping(method = RequestMethod.GET)
    public R getExerciseListByStudent(HttpServletRequest request){
        return R.success(exerciseService.getStuExerciseList(AccessTokenUtil.getUserId(request)));
    }

}
